package com.yu.crm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yu.crm.domain.pojo.CrmDepartmentPositionLevel;
import com.yu.crm.service.CrmDepartmentPositionLevelService;
import com.yxzz.common.BaseController;
import com.yxzz.common.helper.valid.ValidatorHelpers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 部门职位级别表 前端控制器
 * </p>
 *
 * @author donnie-bin
 * @since 2019-06-10
 */
@Api(tags = "部门职位级别管理")
@RestController
@RequestMapping("/crm-department-position-level")
public class CrmDepartmentPositionLevelController {

    @Autowired
    CrmDepartmentPositionLevelService positionTypeService;

    @ApiOperation(value = "详情保存或修改")
    @PostMapping(value = "/save-or-update")
    public void saveOrUpdate(@RequestBody @Valid CrmDepartmentPositionLevel positionLevel, BindingResult bindingResult){
        ValidatorHelpers.validateParams(bindingResult);
        positionTypeService.saveOrUpdate(positionLevel);

    }

    @ApiOperation(value = "根据ID删除")
    @DeleteMapping(value = "/remove-by-id/{id}")
    public void removeById(@PathVariable Long id){
        positionTypeService.removeById(id);
    }

    @ApiOperation(value = "详情查询")
    @GetMapping(value = "/get-by-id/{id}")
    public CrmDepartmentPositionLevel getById(@PathVariable Long id){
        return positionTypeService.getById(id);
    }

    @ApiOperation(value = "分页列表查询")
    @GetMapping(value = "/list")
    public IPage<CrmDepartmentPositionLevel> list(Page<CrmDepartmentPositionLevel> page, CrmDepartmentPositionLevel queryInfo){
        return positionTypeService.list(page, queryInfo);
    }
}

